package com.copsoftware.utils.beans;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class DateUtils {
	  
	static final long ONE_HOUR = 60 * 60 * 1000L;
	
	public static long daysBetween(Date d1, Date d2){
	    return ( (d2.getTime() - d1.getTime() + ONE_HOUR) / 
	                  (ONE_HOUR * 24));
	     } 
	public static Date calculateNewDate(Date fechaInicial,long days)
	{		 
		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(fechaInicial);
		cal.add(Calendar.DAY_OF_YEAR, new Long(days).intValue());
		Date newDate = cal.getTime();
		return newDate;
	}
	
	public static String dateToString(Date fecha)
	{
		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(fecha);
		return cal.get(Calendar.DAY_OF_MONTH)+"/"+(cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.YEAR);
	}
	
	public static void main (String []args)
	{
		System.out.println(DateUtils.dateToString(new Date()));
	}
		
}
